全部文档

3产品管理

提供物联网平台创建边缘终端产品、编辑删除产品的功能以及根据产品的ID查询产品详细信息和分页查询产品列表信息的功能。

3.1创建边缘终端产品

3.1.1创建边缘终端产品(非视频类)

功能描述:提供产品对象新建,返回产品的id和masterKey,用于产品信息鉴权。

POST  /api/v1/products

Body:

Name Type Description Required
name string 产品名称 Yes
protocolType int 产品协议 (1 : MQTT; 4 : Modbus; 5 : OPC UA; 7 : BACnet) Yes
nodeType int 节点类型 (1 : 设备) Yes
model int 产品模式 (1:物模型) Yes
dataFormat int 数据类型 (1:标准数据类型 ;2:自定义透传数据类型;3 : Modbus rtu) Yes
description string 产品描述信息 No
manufacturer string 制造商(备用扩展字段) No
category int 产品分类描述(备用扩展字段) No
netType int 产品网络连接分类(备用扩展字段) No
networkMethod int 联网方式 1-蜂窝, 2-wifi, 3-以太网, 4-其他 Yes
categoryId int 行业物模板ID(不传则产品类型为自定义格式,否则为标准行业格式) No
authenticationMethod int 产品认证方式 (1:设备密钥; 2:证书认证) No(默认值为1)

下表格为参数protocolType与model,dataFormat, nodeType之间的关系表。

protocolType nodeType model dataFormat
MQTT 设备 物模型 标准数据格式
Modbus 设备 物模型 Modbus rtu
OPC UA 设备 物模型
BACnet 设备 物模型 标准数据格式

Body example:

{
  "dataFormat": 1,
  "description": "string",
  "manufacturer": "string",
  "model": 1,
  "name": "strin12322",
  "nodeType": 1,
  "networkMethod": 1,
  "protocolType": 1
}

cURL example:

   curl --location --request POST '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/products?accessKeyId={accessKeyId}&signature={signature}&signatureNonce=646' \
   --header 'platform: 3' \
   --header 'projectId: {projectId}' \
   --header 'Content-Type: application/json' \
   --data-raw '{    
     "dataFormat": 1,
     "description": "string",
     "manufacturer": "string",
     "model": 1,
     "name": "strin12322",
     "nodeType": 1,
     "networkMethod": 1,
     "protocolType": 1    
   }'

Response data:

Name Type Description
id int 产品ID
masterKey string 秘钥

Response example:

{
  "success": true,
  "code": 0,
  "msg": "",
  "data": {
    "id": 100109,
    "masterKey": "NTFjYzRiNDNmNGUzZmNhMDYyODQ="
  }
}

3.1.2创建边缘终端产品(视频类)

Name Type Description Required
name string 产品名称 Yes
industry string 产品行业 Yes
categoryId int 产品类型 Yes
description string 产品简介 No
os string 操作系统 Yes
carrier string 运营商 Yes
connection string 联网方式 Yes
protocolType int 接入协议 Yes
nodeType int 节点类型 (1 : 设备) Yes
model int 产品模式 (1:物模型) Yes
dataFormat int 数据类型 (1:标准数据类型 ;2:自定义透传数据类型;3 : Modbus rtu) Yes
category int 产品分类描述(备用扩展字段) Yes
user_id string 用户id Yes

Body example:

{
    "name":"test-p-041-11",
    "industry":"9",
    "categoryId":100004
    "description":"feeerese",
    "os":"Android",
    "carrier":"1",
    "connection":1,
    "protocolType":15,
    "nodeType":1,
    "model":1,
    "dataFormat":1,
    "category":1,
    "user_id":"3799722e-54fe-417e-b3f6-a277b8a76517"
}

cURL example:

curl --location --request POST '{URI-scheme}://{Endpoint}{path-prefix}/api/open/v1/products?accessKeyId={accessKeyId} \
--header 'platform: 3' \
--header 'userId: 3799722e-54fe-417e-b3f6-a277b8a76517' \
--header 'projectId: 559a2be0-aaaa-46a4-91c4-06dc7f6d39a1' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name":"test-p-041-20277",
    "industry":"9",
    "categoryId":100004,
    "description":"feeereses",
    "os":"Android",
    "carrier":"1",
    "connection":1,
    "protocolType":15,
    "model":1,
    "nodeType":1,
    "dataFormat":1,
    "category":1,
    "user_id":"3799722e-54fe-417e-b3f6-a277b8a76517"
}'

Response data:

Name Type Description
id int 产品ID
masterKey string 秘钥

Response example:

{
  "success": true,
  "code": 0,
  "msg": "",
  "data": {
    "id": 100109,
    "masterKey": "NTFjYzRiNDNmNGUzZmNhMDYyODQ="
  }
}

3.2根据产品ID查询产品信息

功能描述:根据产品的id查询产品,返回产品详细信息。

GET  /api/v1/products/{productId}

Path:

Name Type Description Required
productId int 产品ID Yes

cURL example:

   curl --location --request GET '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/products/{productId}?accessKeyId={accessKeyId}&signature={signature}&signatureNonce=646' \
   --header 'platform: 3' \
   --header 'projectId: {projectId}'

Response data:

Name Type Description
userId string 用户ID
name string 产品名称
created long 创建时间
modified long 修改时间
description string 描述
manufacturer string 制造商
category int 产品分类描述
netType int 产品网络连接分类
model int 产品模式 (1:物模型)
dataFormat int 数据类型 (1:标准数据类型 ;3 : Modbus rtu)
nodeType int 节点类型 (1 : 设备)
protocolType int 协议类型
masterKey string 秘钥
userName string 用户名称
platform int 平台类型
dynamicRegister int 标志是否开启动态注册 0-关闭, 1-开启
authenticationMethod int 产品认证方式 1-设备密钥, 2-证书认证
deviceCount long 设备数量
onlineDeviceCount long 在线设备数量
enableDeviceCount long 启用设备数量
id int 产品ID
categoryId int 品类ID
networkMethod int 联网方式 1-蜂窝, 2-wifi, 3-以太网, 4-其他

Response example:

{
  "success": true,
  "code": 0,
  "msg": null,
  "data": {
                    "userId": "1bb9909ee93647df883b9043743a345d",
                    "name": "string123422",
                    "created": 1588821676143,
                    "modified": 1588821676143,
                    "description": "string",
                    "manufacturer": "string",
                    "category": 0,
                    "netType": 0,
                    "model": 1,
                    "dataFormat": 1,
                    "nodeType": 1,
                    "protocolType": 1,
                    "masterKey": "YzZmYjFjYWM5Nzc2Y2EzMDQzNzA=",
                    "userName": null,
                    "platform": 1,
                    "dynamicRegister": 0,
                    "authenticationMethod": 1,
                    "deviceCount": 0,
                    "onlineDeviceCount": 0,
                    "enableDeviceCount": 0,
                    "id": 100688,
                    "categoryId": 24,
                    "networkMethod": 1
              }
}

3.3查询产品列表信息

功能描述:用于产品分页查询,指定当前分页和分页大小。返回具体分页信息和产品查询列表。

GET  /api/v1/products

Query:

Name Type Description Required
pageSize int 分页大小 Yes
currentPage int 页码 Yes
name string 产品名,模糊查询 No

cURL example:

   curl --location --request GET '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/products?accessKeyId={accessKeyId}&signature={signature}&signatureNonce=646&currentPage={currentPage}&pageSize={pageSize}' \
   --header 'platform: 3' \
   --header 'projectId: {projectId}'

Response data:

Name Type Description
totalCount int 总数量
pageSize int 分页大小
currentPage int 页码
totalPage int 总页数
content struct[] 内容

Response data content的子对象结构体:

Name Type Description
userId string 用户ID
name string 产品名称
created long 创建时间
modified long 修改时间
description string 描述
manufacturer string 制造商
category int 产品分类描述
netType int 产品网络连接分类
model int 产品模式 (1:物模型)
dataFormat int 数据类型 (1:标准数据类型 ;3 : Modbus rtu)
nodeType int 节点类型 (1 : 设备)
protocolType int 协议类型
masterKey string 秘钥
userName string 用户名称
platform int 平台类型
dynamicRegister int 标志是否开启动态注册 0-关闭, 1-开启
authenticationMethod int 产品认证方式 1-设备密钥, 2-证书认证
deviceCount long 设备数量
onlineDeviceCount long 在线设备数量
enableDeviceCount long 启用设备数量
id int 产品ID
categoryId int 品类ID
networkMethod int 联网方式 1-蜂窝, 2-wifi, 3-以太网, 4-其他

Response example:

{
  "success": true,
  "code": 0,
  "msg": "",
  "data": {
    "totalCount": 4,
    "pageSize": 1,
    "currentPage": 1,
    "totalPage": 4,
    "content": [
                        {
                            "userId": "1bb9909ee93647df883b9043743a345d",
                            "name": "string123422",
                            "created": 1588821676143,
                            "modified": 1588821676143,
                            "description": "string",
                            "manufacturer": "string",
                            "category": 0,
                            "netType": 0,
                            "model": 1,
                            "dataFormat": 1,
                            "nodeType": 1,
                            "protocolType": 1,
                            "masterKey": "YzZmYjFjYWM5Nzc2Y2EzMDQzNzA=",
                            "userName": null,
                            "platform": 1,
                            "dynamicRegister": 0,
                            "authenticationMethod": 1,
                            "deviceCount": 0,
                            "onlineDeviceCount": 0,
                            "enableDeviceCount": 0,
                            "id": 100688,
                            "categoryId": 24,
                            "networkMethod": 1
                        },
      ...
    ]
  }
}

3.4更改产品

功能描述:根据产品id和将要更改的产品属性对产品进行更改。

PUT  /api/v1/products/{productId}

Path:

Name Type Description Required
productId int 产品ID Yes

Body:

Name Type Description Required
name string 产品名字 No
description string 产品描述 No

Body example:

{
  "name": "stringer"
}

cURL example:

   curl --location --request PUT '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/products/{productId}?accessKeyId={accessKeyId}&signature={signature}&signatureNonce=646' \
   --header 'platform: 3' \
   --header 'projectId: {projectId}' \
   --header 'Content-Type: application/json' \
   --data-raw '{
     "name": "stringer"
   }'

Response example:

{
  "success": true,
  "code": 0,
  "msg": null,
  "data": null
}

3.5删除产品

功能描述:根据产品id删除指定产品。

DELETE  /api/v1/products/{productId}

注:删除产品时会将产品下的设备和脚本同时删除,慎用!!!

Path:

Name Type Description Required
productId int 产品ID Yes

cURL example:

   curl --location --request DELETE '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/products/{productId}?accessKeyId={accessKeyId}&signature={signature}&signatureNonce=646' \
   --header 'platform: 3' \
   --header 'projectId: {projectId}'

Response example:

{
  "success": true,
  "code": 0,
  "msg": null,
  "data": null
}

3.6分页模糊查询所有产品list

功能描述:用于查询所有产品,用户的accessKeyId需要是顶层用户(本平台的第一个初始化用户)的accessKeyId,指定当前分页和分页大小,分页大小最大1000条记录。返回具体分页信息和产品查询列表。

GET  /api/v1/products/all

Query:

Name Type Description Required
pageSize int 分页大小 Yes
currentPage int 页码 Yes
name string 产品名,模糊查询 No

cURL example:

    curl --location --request GET '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/products/all?accessKeyId={accessKeyId}&signature={signature}&signatureNonce=646&currentPage={currentPage}&pageSize={pageSize}' \
    --header 'platform: 3'

Response example:

{
    "code": 0,
    "data": {
        "totalPage": 6,
        "pageSize": 2,
        "currentPage": 1,
        "totalCount": 11,
        "content": [
            {
                "masterKey": "YmI2NTA0YjVhNmVjMzI0ZGZiZGI=",
                "description": "",
                "categoryName": "",
                "platform": 1,
                "manufacturer": "",
                "networkMethod": 1,
                "dynamicRegister": 0,
                "modified": 1600939035638,
                "model": 0,
                "id": 100030,
                "onlineDeviceCount": 0,
                "deviceCount": 0,
                "created": 1600939035638,
                "netType": 0,
                "dataFormat": 3,
                "enableDeviceCount": 0,
                "protocolType": 3,
                "nodeType": 3,
                "userName": null,
                "userId": "3799722e-54fe-417e-b3f6-a277b8a76517",
                "field": "",
                "authenticationMethod": 1,
                "name": "556",
                "category": null,
                "categoryId": 0
            },
            {
                "masterKey": "MWUwYTI2ZjA1ZDFlN2QwMGM2NDg=",
                "description": "",
                "categoryName": "",
                "platform": 1,
                "manufacturer": "",
                "networkMethod": 1,
                "dynamicRegister": 0,
                "modified": 1600939015785,
                "model": 1,
                "id": 100029,
                "onlineDeviceCount": 0,
                "deviceCount": 0,
                "created": 1600939015785,
                "netType": 0,
                "dataFormat": 1,
                "enableDeviceCount": 0,
                "protocolType": 1,
                "nodeType": 2,
                "userName": null,
                "userId": "3799722e-54fe-417e-b3f6-a277b8a76517",
                "field": "",
                "authenticationMethod": 1,
                "name": "3454",
                "category": null,
                "categoryId": 0
            }
        ]
    },
    "msg": "成功",
    "referInfo": null,
    "success": true
}

results matching ""

    No results matching ""